﻿//企业类型统计图表
var vPleaceChart = {
    chart: {
        renderTo: 'DivPleaceChart',
        plotBackgroundColor: null,
        borderRadius: 0,
        plotBorderWidth: null,
        plotShadow: false
    },
    title: {
        text: null
    },
    credits: {
        href: '#',
        text: ' '
    },
    subtitle: {
        text: null
    },
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'

    },
    plotOptions: {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
                enabled: true,
                color: '#000000',
                connectorColor: '#000000',
                formatter: function () {
                    return '<b>' + this.point.name + '</b>: ' + $MCVT.ToDecimal(this.percentage, 2) + ' %';
                }
            }
        }
    },
    series: [{
        type: 'pie',
        name: '地区比例',
        data: []
    }]
}
//企业类型统计图表
var vTypeChart = {
    chart: {
        renderTo: 'DivTypeChart',
        type: 'column'
    },
    credits: {
        href: '#',
        text: ' '
    },
    title: {
        text: null
    },
    subtitle: {
        text: null
    },
    xAxis: {
        categories: []
    },
    yAxis: {
        tickPositions: [0, 20, 40, 60, 80, 100],
        layout: 'vertical',
        title: {
            // rotation: 0,
            text: '投运率%'
        }
    },
    tooltip: {
        formatter: function () {
            var point = this.point,
                        s = this.x + ':<b>' + this.y + '%</b><br/>';
            return s;
        }
    },
    legend: {
        enabled: false
    },
    series: [{
        //name: '昨日投运率',
        data: []
        //color: 'white'
    }],
    exporting: {
        enabled: false
    }
}

$MET.Load.Install(function () {
    ChekPageRight(1001, 3); //验证页面访问权限
    //所有企业信息
    $('#DivInfo').datagrid({
        title: '设备在线统计',
        width: 517,
        height: 295,
        showFooter: true,
        fitColumns: true,
        singleSelect: true,
        rownumbers: true,
        columns: [[
                    { field: 'AreaName', width: 50, title: '区县', align: 'center' },
                    { field: 'AreaPollSourceCount', title: '企业数', align: 'center' },
                    { field: 'AreaComCount', title: '监控数', align: 'center' },
                    { field: 'AreaComOnline', title: '在线数', align: 'center' },
                    { field: 'AreaComOffLine', title: '离线数', align: 'center' },
                    { field: 'AreaComOnlineRate', title: '在线率', align: 'center' },
                    //{
                    //    field: '8', title: '更多', width: 18, rowspan: 2, align: 'center',
                    //    formatter: function (value, rowData, rowIndex) {
                    //        //获取数据信息
                    //        var CoordinateX = rowData.CoordinateX;
                    //        var CoordinateY = rowData.CoordinateY;
                    //        var EnterpriseMan = rowData.EnterpriseMan;
                    //        var EnterprisePhone = rowData.EnterprisePhone;
                    //        var EnterpriseMobile = rowData.EnterpriseMobile;
                    //        var EnterpriseAddress = rowData.EnterpriseAddress;
                    //        //拼接提示信息
                    //        var Title = "经度：" + CoordinateX + "\n纬度：" + CoordinateY;
                    //        Title += "\n企业联系人：" + EnterpriseMan + "\n联系人电话：" + EnterprisePhone;
                    //        Title += "\n联系人手机：" + EnterpriseMobile + "\n联系人地址：" + EnterpriseAddress;

                    //        return "<img alt='' title='" + Title + "' src='../../Image/Ico/More.png' style='width:25px;height:25px;' /></a>";
                    //    }
                    //}
        ]]
    });
    //载入数据
    var RTUrl = "SourceInformation.ashx";
    var RTData = "action=GetComStatus";
    $MRT.Ajax(true, RTUrl, RTData, function (xmlData, state) {
        var Json = $MJO.GetObject(xmlData);
        if (xmlData != "nodata") {
            //获取集合数量
            var Total = Json.Data.length;

            var TotalAreaPollSourceCount = Json.Data[0].TotalAreaPollSourceCount;
            var TotalAreaComCount = Json.Data[0].TotalAreaComCount;
            var TotalAreaComOnline = Json.Data[0].TotalAreaComOnline;
            var TotalComOffLine = Json.Data[0].TotalComOffLine;
            var AvgAreaComOnlineRate = Json.Data[0].AvgAreaComOnlineRate;
            var LoadData = $MJO.GetObject('{ "total": ' + Total + ', "rows": [],"footer":[{"AreaPollSourceCount":'
                + TotalAreaPollSourceCount
                + ',"AreaComCount":'
                + TotalAreaComCount
                + ',"AreaComOnline":'
                + TotalAreaComOnline
                + ',"AreaComOffLine":'
                + TotalComOffLine
                + ',"AreaComOnlineRate":"'
                + AvgAreaComOnlineRate
                + '","AreaName":"合计:"} ]}');

            LoadData.rows = Json.Data;
            //载入数据
            $('#DivInfo').datagrid('loadData', LoadData);
            if (Json.Data.length <= 0)
                $.messager.alert("提示", "无任何相关信息.");
        }
        else {
            $.messager.alert('提示', '搜索信息数据失败.');
        }
    });

    $('#DivRate').datagrid({
        title: '投运率统计',
        width: 517,
        height: 295,
        showFooter: true,
        fitColumns: true,
        singleSelect: true,
        rownumbers: true,
        columns: [[
                    { field: 'AreaName', width: 50, title: '区县', align: 'center' },
                    { field: 'AreaPollSourceCount', title: '企业数', align: 'center' },
                    { field: 'AreaComCount', title: '监控数', align: 'center' },
                    { field: 'AreaRateYestoday', title: '昨日投运率', align: 'center' },
                    { field: 'AreaRatetoday', title: '今日投运率', align: 'center' }
        ]]
        //,
        //onLoadSuccess: function (data) {
        //    alert();
        //}
    });
    //载入数据
    var RTUrl = "http://221.226.58.230:8024/WebSite/Branch/SourceInformation.ashx";
    var RTData = "action=GetComRate";
    $MRT.Ajax(true, RTUrl, RTData, function (xmlData, state) {
        var Json = $MJO.GetObject(xmlData);
        if (xmlData != "nodata") {
            //获取集合数量
            var Total = Json.Data.length;


            var TotalAreaPollSourceCount = Json.Data[0].TotalAreaPollSourceCount;
            var TotalAreaComCount = Json.Data[0].TotalAreaComCount;
            var TotalAreaComOnline = Json.Data[0].TotalAreaComOnline;
            var TotalComOffLine = Json.Data[0].TotalComOffLine;
            var AvgAreaRateYestoday = Json.Data[0].AvgAreaRateYestoday;
            var AvgAreaRatetoday = Json.Data[0].AvgAreaRatetoday;

            var LoadData = $MJO.GetObject('{ "total": ' + Total + ', "rows": [],"footer":[{"AreaPollSourceCount":'
                + TotalAreaPollSourceCount
                + ',"AreaComCount":'
                + TotalAreaComCount
                + ',"AreaRateYestoday":"'
                + AvgAreaRateYestoday
                + '","AreaRatetoday":"'
                + AvgAreaRatetoday
                + '","AreaName":"合计:"} ]}');

            LoadData.rows = Json.Data;
            //载入数据
            $('#DivRate').datagrid('loadData', LoadData);
            if (Json.Data.length <= 0)
                $.messager.alert("提示", "无任何相关信息.");
        }
        else {
            $.messager.alert('提示', '搜索信息数据失败.');
        }
    });

    //企业地区统计
    RTUrl = "../../../Service/Expand/SourceInformation/SourceOverview/GetSourcePleaceGroup.ashx";
    RTData = "";
    $MRT.Ajax(true, RTUrl, RTData, function (xmlData, state) {
        var Json = $MJO.GetObject(xmlData);

        if (Json != null && Json.Successful == true) {
            var Series = [];
            for (var I in Json.Data) {
                var Serie = [];

                Serie.push(Json.Data[I].PleaceName);
                Serie.push(Json.Data[I].PleaceGroupSum);

                Series.push(Serie);
            }
            vPleaceChart.series[0].data = Series;
            new Highcharts.Chart(vPleaceChart);
        }
    });
    //企业类型统计
    var RTUrl = "http://221.226.58.230:8024/WebSite/Branch/SourceInformation/SourceInformation.ashx";
    RTData = "action=GetAreaRunRate";
    $MRT.Ajax(true, RTUrl, RTData, function (xmlData, state) {
        var Json = $MJO.GetObject(xmlData);
        if (Json != null && Json != "nodata") {
            var xAxiss = [];
            var Series = [];
            for (var I in Json.Area) {
                var Serie = new Object();
                Serie.y = Json.Area[I].Value - 0;
                Serie.color = '#' + ('00000' + (Math.random() * 0x1000000 << 0).toString(16)).slice(-6);
                Series.push(Serie);
                xAxiss.push(Json.Area[I].PleaceName);
            }
            vTypeChart.xAxis.categories = xAxiss;
            vTypeChart.series[0].data = Series;

            new Highcharts.Chart(vTypeChart);
        }
    });
});
document.write("<l" + "ink type='text/css' src='SourceOverview.html.css?" + Math.random() + "'/>");



